package test.websocket;

import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.client.WebSocketConnectionManager;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.handler.TextWebSocketHandler;

public class MonitorWebSocketClient {
	
	public static void main(String[] args) {
		
		StandardWebSocketClient  client = new StandardWebSocketClient();
		MyHandler handler = new MyHandler();
		WebSocketConnectionManager manager = new WebSocketConnectionManager(client , handler , "ws://localhost");
		manager.start();
		
		
		boolean run = true;
		while (run) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				run = false;
			}
		}
		
		manager.stop();
		
	}
	
	private static class MyHandler extends TextWebSocketHandler {
		@Override
		public void afterConnectionEstablished(WebSocketSession session) throws Exception {
		}
		@Override
		protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
		}
	}
}
